package com.wangsb.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @Author: shenbing.wang
 * @CreateDate: 2021/2/2 22:33
 * @Version: 1.0
 * @Description:
 */
@Controller
public class MappingController {

    @GetMapping(value = "/mapping", params = {"username!=汪神兵"})
    public String mapping01() {
        return "/index.jsp";
    }

    //consumes  请求内容类型的限制
    @PostMapping(value = "/consumer", consumes = {"application/x-www-form-urlencoded"})
    public String consumer() {
        return "/index.jsp";
    }

    //produces  响应内容类型
    @RequestMapping(value = "/produces", produces = {"application/json"})
    public String produces() {
        System.out.println("响应内容类型");
        return "/index.jsp";
    }

    //如果映射存在包含关系会优先交给更精确的那个映射处理
    // 1、？   一个？ 匹配单个字符
    //2 、*  一个*匹配多个字符
    //3、**  多个可以有多个层级关系
    @RequestMapping(value = "/ant?")
    public String ant() {
        System.out.println("?");
        return "/index.jsp";
    }

    @RequestMapping(value = "/ant*")
    public String ant2() {
        System.out.println("*");
        return "/index.jsp";
    }

    @RequestMapping(value = "/**/ant/**")
    public String ant3() {
        System.out.println("**");
        return "/index.jsp";
    }
}
